package com.scuec.trainingmanagementsys.service.impl;

import com.scuec.trainingmanagementsys.entity.Team;
import com.scuec.trainingmanagementsys.mapper.TeamMapper;
import com.scuec.trainingmanagementsys.service.TeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TeamServiceImpl implements TeamService {

    @Autowired
    private TeamMapper teamMapper;

    @Override
    public int addTeam(Team team) {
        return teamMapper.addTeam(team);
    }

    @Override
    public int deleteTeam(Integer teamID) {
        return teamMapper.deleteTeam(teamID);
    }

    @Override
    public int updateTeam(Team team) {
        return teamMapper.updateTeam(team);
    }

    @Override
    public Team getTeam(Integer teamID) {
        return teamMapper.getTeam(teamID);
    }

    @Override
    public List<Team> getAllTeams() {
        return teamMapper.getAllTeams();
    }

    @Override
    public List<Team> listWithRelations() {
        return teamMapper.listWithRelations(); // 调用联表查询
    }


    @Override
    public List<Map<String, Object>> getTeamMembers(Integer teamID) {
        // 这里通过 teamMapper 调用对应的方法查询团队成员数据并返回，示例逻辑，需结合实际Mapper方法
        return teamMapper.getTeamMembers(teamID);
    }

    @Override
    public List<Team> getTeamsByProjectId(Integer projectId) {
        return teamMapper.getTeamsByProjectId(projectId);
    }
}
